<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../css/swiper.min.css"/>
    <style>
        html, body {
            background-color: #f8f8f8;
        }
        .location_box {
            background-color: #e62442;
            padding-bottom: 10px;
        }
        .location_box .location {
            display: -webkit-box;
            -webkit-box-align: center;
            -webkit-box-pack: center;
            margin: auto;
            padding: 15px 0;
        }
        .location_box .location img {
            height: 17px;
            display: block;
        }
        .location_box .location span {
            color: #fff;
            font-size: 17px;
            margin-left: 7px;
            display: block;
        }
        .search_wrap {
            width: 100%;
            padding: 0 15px;
            box-sizing: border-box;
            position: absolute;
            top: -15px;
            z-index: 999;
        }
        .search_box {
            height: 31px;
            line-height: 31px;
            background-color: #fff;
            color: #999;
            font-size: 12px;
            border-radius: 5px;
            box-shadow: 1px 1px 2px 0px rgba(0, 0, 0, 0.2);
            display: -webkit-box;
            -webkit-box-align: center;
            -webkit-box-pack: center;
        }
        .search_box img {
            width: 13px;
            display: block;
            margin-right: 6px;
        }
        .search_box input::-webkit-input-placeholder {
            color: #999;
        }
        .search_fixed {
            position: fixed;
            top: 0;
            background-color: #e62442;
            padding: 30px 15px 9px;
            transition: all .3s;
            -webkit-transition: all .3s;
        }
        .banner {
            height: 167px;
            position: relative;
        }
        .banner .swiper-container {
            height: 100%;
        }
        .banner .swiper-container img {
            width: 100%;
            height: 100%;
        }
        .nav {
            padding: 20px 6px 8px;
            background-color: #fff;
            margin-bottom: 6px;
        }
        .nav ul {
            overflow: hidden;
        }
        .nav ul li {
            width: 25%;
            float: left;
            margin-bottom: 12px;
        }
        .nav ul li .li_box {
            text-align: center;
        }
        .nav ul li .li_box .img_box {
            width: 48px;
            height: 48px;
            border-radius: 50%;
            overflow: hidden;
            background-size: 100% 100%;
            background-repeat: no-repeat;
            margin: auto;
            display: -webkit-box;
            -webkit-box-align: center;
            -webkit-box-pack: center;
        }
        .nav ul li .li_box .img_box img {
            display: block;
        }
        .nav ul li:nth-child(1) .li_box .img_box {
            background-image: url('../image/nav_bg1.png');
        }
        .nav ul li:nth-child(1) .li_box .img_box img {
            width: 21px;
        }
        .nav ul li:nth-child(2) .li_box .img_box {
            background-image: url('../image/nav_bg2.png');
        }
        .nav ul li:nth-child(2) .li_box .img_box img {
            width: 28px;
        }
        .nav ul li:nth-child(3) .li_box .img_box {
            background-image: url('../image/nav_bg3.png');
        }
        .nav ul li:nth-child(3) .li_box .img_box img {
            width: 21px;
        }
        .nav ul li:nth-child(4) .li_box .img_box {
            background-image: url('../image/nav_bg4.png');
        }
        .nav ul li:nth-child(4) .li_box .img_box img {
            width: 24px;
        }
        .nav ul li:nth-child(5) .li_box .img_box {
            background-image: url('../image/nav_bg5.png');
        }
        .nav ul li:nth-child(5) .li_box .img_box img {
            width: 27px;
        }
        .nav ul li:nth-child(6) .li_box .img_box {
            background-image: url('../image/nav_bg6.png');
        }
        .nav ul li:nth-child(6) .li_box .img_box img {
            width: 26px;
        }
        .nav ul li:nth-child(7) .li_box .img_box {
            background-image: url('../image/nav_bg7.png');
        }
        .nav ul li:nth-child(7) .li_box .img_box img {
            width: 24px;
        }
        .nav ul li:nth-child(8) .li_box .img_box {
            background-image: url('../image/nav_bg8.png');
        }
        .nav ul li:nth-child(8) .li_box .img_box img {
            width: 23px;
        }
        .nav ul li .li_box .p_box {
            color: #333;
            font-size: 13px;
            margin-top: 6px;
        }
        .discount_box {
            background-color: #fff;
            padding: 0 15px 10px;
            margin-bottom: 6px;
        }
        .discount_box .discount_boxt {
            height: 40px;
            line-height: 40px;
            display: -webkit-box;
            -webkit-box-align: center;
        }
        .discount_box .discount_boxt img {
            height: 14px;
            display: block;
            margin-right: 5px;
        }
        .discount_box .discount_boxt span {
            display: block;
            font-size: 15px;
            color: #333;
        }
        .discount_box .discount_boxb {
            overflow: hidden;
        }
        .discount_box .discount_boxb .discount_div {
            width: 50%;
            float: left;
            padding: 0 5px 0 0;
            position: relative;
            box-sizing: border-box;
        }
        .discount_box .discount_boxb .discount_div:last-child {
            padding: 0 0 0 5px;
        }
        .discount_box .discount_boxb .discount_div .discount_img {
            width: 100%;
            height: 92px;
        }
        .discount_box .discount_boxb .discount_div .discount_img img {
            width: 100%;
            object-fit: cover;
            height: 100%;
        }
        .discount_box .discount_boxb .discount_div .discount_p {
            width: 60px;
            height: 16px;
            line-height: 16px;
            font-size: 13px;
            color: #fff;
            background-color: #e62442;
            text-align: center;
            position: absolute;
            left: 0;
            top: 0;
        }
        .discount_box .discount_boxb .discount_div:last-child .discount_p {
            background-color: #ff8003;
            left: 5px;
        }
        .screen_box {
            height: 40px;
            background-color: #fff;
            border-bottom: 1px solid #e8e8e8;
            display: -webkit-box;
            display: -webkit-flex;
            align-items: center;
        }
        .screen_box .location_p {
            padding-left: 15px;
            padding-right: 20px;
            display: -webkit-box;
            -webkit-box-align: center;
        }
        .screen_box .location_p img {
            height: 14px;
            display: block;
            margin-right: 5px;
        }
        .screen_box .location_p span {
            display: block;
            font-size: 15px;
            color: #333;
        }
        .screen_box .screen_div {
            width: 0;
            flex: 1;
            -webkit-flex: 1;
            box-flex: 1;
            -webkit-box-flex: 1;
        }
        .screen_box .screen_div span {
            width: 48px;
            height: 20px;
            line-height: 20px;
            font-size: 12px;
            color: #999;
            text-align: center;
            display: inline-block;
            margin-right: 8px;
        }
        .screen_box .screen_div span:last-child {
            margin-right: 0;
        }
        .screen_box .screen_div span.active {
            color: #fff;
            background-color: #f3b818;
            border-radius: 5px;
        }
        .screen_box .screen {
            height: 40px;
            display: -webkit-box;
            -webkit-box-align: center;
            padding: 0 15px;
        }
        .screen_box .screen img {
            height: 13px;
            display: block;
            margin-right: 5px;
        }
        .screen_box .screen span {
            color: #999;
            font-size: 12px;
            display: block;
        }
        .screen_box_s {
            padding-top: 21px;
            position: relative;
            z-index: 1000;
        }
        .goods_box {
            background-color: #fff;
        }
        .goods_box ul li .li_box {
            padding: 10px 15px;
            box-sizing: border-box;
            border-bottom: 1px solid #e8e8e8;
        }
        .goods_box ul li:last-child .li_box {
            border-bottom: none;
        }
        .goods_box ul li .li_box .li_boxt {
            display: -webkit-box;
            display: -webkit-flex;
            overflow: hidden;
        }
        .goods_box ul li .li_box .li_boxb {
            padding-top: 10px;
        }
        .goods_box .li_img {
            width: 82px;
            height: 59px;
            border-radius: 5px;
        }
        .goods_box .li_img img {
            height: 100%;
            object-fit: cover;
            width: 82px;
            border-radius: 5px;
        }
        .goods_box .li_info {
            padding-left: 10px;
            box-flex:1;
            -webkit-box-flex:1;
            flex:1;
            -webkit-flex:1;
        }
        .goods_box .li_info .title_box {
            overflow: hidden;
        }
        .goods_box .li_info .title_box .title {
            float: left;
            font-size: 16px;
            color: #333;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .goods_box .li_info .title_box .send {
            float: right;
            color: #999;
            font-size: 12px;
        }
        .goods_box .li_info .evaluate {
            display: -webkit-box;
            display: -webkit-flex;
            align-items: center;
            margin-bottom: 3px;
        }
        .goods_box .li_info .evaluate .evaluate_img {
            overflow: hidden;
            margin-right: 3px;
        }
        .goods_box .li_info .evaluate .evaluate_img img {
            width: 9px;
            float: left;
            margin-right: 3px;
        }
        .goods_box .li_info .evaluate .evaluate_img img:last-child {
            margin-right: 0;
        }
        .goods_box .li_info .evaluate .evaluate_num {
            font-size: 12px;
            margin-right: 14px;
            color: #999;
        }
        .goods_box .li_info .evaluate .month_sell {
            flex: 1;
            -webkit-flex: 1;
            box-flex: 1;
            -webkit-box-flex: 1;
            font-size: 12px;
            color: #999;
        }
        .goods_box .li_info .distance {
            font-size: 12px;
            color: #999;
        }
        .goods_box .li_discount {
            font-size: 12px;
            color: #999;
        }
        .goods_box .li_discount span {
            width: 16px;
            height: 16px;
            line-height: 16px;
            text-align: center;
            background-color: #ff5f78;
            color: #fff;
            display: inline-block;
            border-radius: 3px;
            margin-right: 5px;
        }
        .unable_box {
            text-align: center;
            padding-top: 225px;
        }
        .unable_box img {
            width: 42px;
            vertical-align: middle;
        }
        .unable_box p {
            color: #999;
            font-size: 13px;
            margin: 15px 0 35px;
        }
        .unable_box .reload_btn {
            width: 118px;
            height: 41px;
            line-height: 41px;
            font-size: 16px;
            text-align: center;
            color: #fff;
            background-color: #e62442;
            border-radius: 5px;
            margin: auto;
        }
        .location_off_box {
            background-color: rgba(0, 0, 0, 0.5);
            position: fixed;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            z-index: 999;
            padding: 0 45px;
            display: -webkit-box;
            -webkit-box-align: center;
        }
        .location_off_box .popup {
            background-color: #fff;
            border-radius: 5px;
            overflow: hidden;
        }
        .location_off_box .popup .popup_t {
            height: 50px;
            line-height: 50px;
            color: #333;
            font-size: 16px;
            text-align: center;
            border-bottom: 1px solid #e8e8e8;
        }
        .location_off_box .popup .popup_c {
            padding: 15px;
            color: #999;
            font-size: 13px;
            line-height: 23px;
        }
        .location_off_box .popup .popup_b {
            padding-bottom: 15px;
        }
        .location_off_box .popup .popup_b .btn {
            width: 98px;
            height: 38px;
            line-height: 38px;
            text-align-last: center;
            margin: auto;
            color: #fff;
            background-color: #e62442;
            font-size: 15px;
            border-radius: 5px;
            text-align: center;
        }
        .no_position {
            display: none;
        }
        .has_position {
            display: none;
        }
        .swiper-slide img{
            /*object-fit: none;*/
            /*object-fit: contain;*/
            object-fit: cover;
        }
        .without_data{
            text-align: center;
            display: none;
            background: #f8f8f8;
            color: #999;
            line-height: 30px;
        }
        .loading{
            color: #ccc;
            text-align: center;
            line-height: 25px;
            display: none;
            background: #f8f8f8;
        }
    </style>
</head>
<div class="goods_box">
    <ul id="shop_ul">
        <!-- <li tapmode onclick="fnSeller();">
            <div class="li_box">
                <div class="li_boxt">
                    <div class="li_img">
                        <img src="../image/temp/1.png">
                    </div>
                    <div class="li_info">
                        <div class="title_box">
                            <div class="title">商家名称</div>
                            <div class="send">20元起送</div>
                        </div>
                        <div class="evaluate">
                            <div class="evaluate_img">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_off.png">
                            </div>
                            <div class="evaluate_num">4.6</div>
                            <div class="month_sell">月售109单</div>
                        </div>
                        <div class="distance">距离0.43km | 配送费 6元</div>
                    </div>
                </div>
                <div class="li_boxb">
                    <div class="li_discount"><span>减</span>满30减10，满40减15</div>
                </div>
            </div>
        </li>
        <li tapmode onclick="fnSeller();">
            <div class="li_box">
                <div class="li_boxt">
                    <div class="li_img">
                        <img src="../image/temp/1.png">
                    </div>
                    <div class="li_info">
                        <div class="title_box">
                            <div class="title">商家名称</div>
                            <div class="send">20元起送</div>
                        </div>
                        <div class="evaluate">
                            <div class="evaluate_img">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_off.png">
                            </div>
                            <div class="evaluate_num">4.6</div>
                            <div class="month_sell">月售109单</div>
                        </div>
                        <div class="distance">距离0.43km | 配送费 6元</div>
                    </div>
                </div>
                <div class="li_boxb">
                </div>
            </div>
        </li>
        <li tapmode onclick="fnSeller();">
            <div class="li_box">
                <div class="li_boxt">
                    <div class="li_img">
                        <img src="../image/temp/1.png">
                    </div>
                    <div class="li_info">
                        <div class="title_box">
                            <div class="title">商家名称</div>
                            <div class="send">20元起送</div>
                        </div>
                        <div class="evaluate">
                            <div class="evaluate_img">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_on.png">
                                <img src="../image/evaluate_off.png">
                            </div>
                            <div class="evaluate_num">4.6</div>
                            <div class="month_sell">月售109单</div>
                        </div>
                        <div class="distance">距离0.43km | 配送费 6元</div>
                    </div>
                </div>
                <div class="li_boxb">
                </div>
            </div>
        </li> -->
    </ul>
<p class="without_data">暂无数据！</p>
<div class="loading">loading...</div>
</div>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script id="shopTpl" type="text/x-dot-template">
    {{ for(var i=0;i<it.length;i++){ }}
        <li onclick="fnOpenSeller({{=it[i]['shop_id']}});" tapmode>
            <div class="li_box">
                <div class="li_boxt">
                    <div class="li_img">
                        <img src="../image/default.png">
                        <img onload="setImg(this);" class="hidden_img" src="{{=formatVideoImg(it[i]['img'])}}">
                    </div>
                    <div class="li_info">
                        <div class="title_box">
                            <div class="title">{{=it[i]['name']}}</div>
                            <div class="send">RM{{=it[i]['start_delivery']}}起送</div>
                        </div>
                        <div class="evaluate">
                            <div class="evaluate_img">
                                {{if(it[i]['full_star'] > 0){  }}
                                    {{ for(var j=0;j<it[i]['full_star'];j++){ }}
                                        <img src="../image/evaluate_on.png">
                                    {{ }; }}
                                {{ }; }}
                                {{if(it[i]['half_star'] > 0){  }}
                                    <img src="../image/evaluate_half.png">
                                {{ }; }}
                                {{if(it[i]['off_star'] > 0){  }}
                                    {{ for(var j=0;j<it[i]['off_star'];j++){ }}
                                        <img src="../image/evaluate_off.png">
                                    {{ }; }}
                                {{ }; }}

                            </div>
                            <div class="evaluate_num">{{=it[i]['score_format']}}</div>
                            <div class="month_sell">月售{{=it[i]['month_sale']}}单</div>
                        </div>
                        <div class="distance">距离{{=it[i]['distance']}}km | 配送费 RM{{=it[i]['express']}}</div>
                    </div>
                </div>
                <div class="li_boxb">
                    {{if(it[i]['coupon_str']){ }}
                        <div class="li_discount"><span>减</span>{{=it[i]['coupon_str']}}</div>
                    {{ }; }}
                </div>
            </div>
        </li>
    {{ }; }}
</script>

<script type="text/javascript">

    var p = 1;
    var canLoad = false;

    apiready = function(){
        fnGetShop(1);

        //上拉加载
        api.addEventListener({
            name:'scrolltobottom',
            extra:{
                threshold:0            //设置距离底部多少距离时触发，默认值为0，数字类型
            }
        }, function(ret, err){
            if(canLoad) {
                canLoad = false;
                p++;
                fnGetShop(2);

            }
        });

        //下拉刷新
        api.setCustomRefreshHeaderInfo({
            bgColor: '#f8f8f8',
            loadAnimInterval:60,
            image: {
               pull: pullArr,
               load: loadArr
            }
        }, function(ret, err) {
            p = 1;
            canLoad = false;
            fnGetShop(1);
        });

    };

    function fnGetShop(type) {
        openLoading();
        var lat = api.pageParam.lat;
        var lng = api.pageParam.lng;
        api.ajax({
            url: rootPath+'/api/shop/get_activity_shops',
            method: 'get',
            cache: true,
            timeout:10,
            data: {
                values: {
                    p:p,
                    page_num:10,
                    lat:lat,
                    lng:lng
                },
            }
        }, function(ret, err) {
            //type=1 下拉刷新，清除原来数据
            if(type == 1) {
                $('#shop_ul').empty();
            }
            if (ret) {
                if(ret.status == 200) {
                    $('.without_data').hide();
                    fnSetShop(ret.data);
                    if(ret.data.length == 10){
                        canLoad = true;
                        p++;
                    }
                }else {
                    if(p == 1) {
                        $('.without_data').show();
                    }
                }
            } else {
                api.toast({
                    msg: err.msg,
                    location : 'middle'
                });
            }
            if(type == 1) {
                // 是下拉刷新的，要收回
                api.refreshHeaderLoadDone();
            }
            if(type == 2) {
                //上拉给点假时间,好看些
                setTimeout(function(){
                    $(".loading").hide();
                },1000);
            }else {
                $('.loading').hide();

            }
            closeLoading();
        });
    }


    function fnSetShop(data_) {
        var listT = $api.byId('shopTpl');
        var listTFn = doT.template(listT.text);
        var html = listTFn(data_);
        var list = $api.byId('shop_ul');
        $api.append(list, html);
        api.parseTapmode();
    }


</script>
